home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 June / june_2000.iso / Site Building / JavaNavigator / JavaNavigator.exe / %MAINDIR% / files / JClass / JAVATab2.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-05-11  |  11.2 KB  |  525 lines

  1. import java.applet.Applet;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Dimension;
  6. import java.awt.Event;
  7. import java.awt.Font;
  8. import java.awt.Graphics;
  9. import java.awt.Image;
  10. import java.awt.Label;
  11. import java.awt.LayoutManager;
  12. import java.awt.MediaTracker;
  13. import java.awt.Panel;
  14. import java.net.MalformedURLException;
  15. import java.net.URL;
  16. import java.util.NoSuchElementException;
  17. import java.util.StringTokenizer;
  18.  
  19. public class JAVATab2 extends Applet implements Runnable {
  20.    String sDefMO = "1st JAVA Navigator[Tab], (c)1997-2000 AUSCOMP - World Wide (www.auscomp.com)";
  21.    String sCopyright = "AUSCOMP (www.auscomp.com)";
  22.    int xSwitch = 3;
  23.    String sLoading = "1st JAVA Navigator V5.5";
  24.    Thread thJAVATab;
  25.    String[] aHref;
  26.    String[] aFrame;
  27.    String[] aHref2;
  28.    String[] aFrame2;
  29.    String[] aMsg;
  30.    String[] tempString;
  31.    String sText = "";
  32.    String sHref = "";
  33.    String sFrame = "";
  34.    String sHref2 = "";
  35.    String sFrame2 = "";
  36.    String sMsg = "";
  37.    String sMsgOld = "";
  38.    int iLoading;
  39.    int iTabCnt;
  40.    int oldx;
  41.    int iTabDefault = 999;
  42.    int iBGRed = 255;
  43.    int iFGRed;
  44.    int iBHRed;
  45.    int iFHRed = 255;
  46.    int iBGGreen = 255;
  47.    int iFGGreen;
  48.    int iBHGreen;
  49.    int iFHGreen = 255;
  50.    int iBGBlue = 255;
  51.    int iFGBlue;
  52.    int iBHBlue;
  53.    int iFHBlue;
  54.    Font fFont = new Font("Dialog", 0, 12);
  55.    private boolean bCopyright = false;
  56.    private boolean allLoaded = false;
  57.    Image imgBG;
  58.    // $FF: renamed from: g1 java.awt.Graphics
  59.    Graphics field_0;
  60.    boolean fAuscomp = true;
  61.    String sMOUSEOVERSOUND = "none";
  62.    String sMOUSECLICKSOUND = "none";
  63.    int oldTabPanel = -1;
  64.    TabPanel tabPanel1;
  65.    Label label1;
  66.  
  67.    void tabPanel1_MouseMove(Event event) {
  68.       int x = 0;
  69.  
  70.       try {
  71.          x = this.tabPanel1.setTabLabelColor(event);
  72.  
  73.          try {
  74.             if (this.oldTabPanel != x && !this.sMOUSEOVERSOUND.equals("none")) {
  75.                ((Applet)this).play(((Applet)this).getCodeBase(), this.sMOUSEOVERSOUND);
  76.             }
  77.  
  78.             this.oldTabPanel = x;
  79.          } catch (Exception var3) {
  80.          }
  81.  
  82.          if (x == 999 && this.oldx != 999) {
  83.             this.tabPanel1.setMOLabelColor(this.tabPanel1.getMOColor(), x);
  84.             this.sMsg = this.sDefMO;
  85.          } else {
  86.             this.sMsg = this.aMsg[x];
  87.          }
  88.  
  89.          this.oldx = x;
  90.          this.sMsg = this.sMsg.trim();
  91.          if (this.sMsg != this.sMsgOld) {
  92.             if (this.sMsg.toLowerCase().equals("none")) {
  93.                ((Applet)this).showStatus(" ");
  94.             } else {
  95.                ((Applet)this).showStatus(this.sMsg);
  96.             }
  97.  
  98.             this.sMsgOld = this.sMsg;
  99.             return;
  100.          }
  101.       } catch (ArrayIndexOutOfBoundsException var4) {
  102.       }
  103.  
  104.    }
  105.  
  106.    void tabPanel1_MouseUp(Event event) {
  107.       try {
  108.          if (!this.sMOUSECLICKSOUND.equals("none")) {
  109.             ((Applet)this).play(((Applet)this).getCodeBase(), this.sMOUSECLICKSOUND);
  110.          }
  111.       } catch (Exception var6) {
  112.       }
  113.  
  114.       try {
  115.          int iTabIx = this.tabPanel1.getCurrentPanelNdx();
  116.          this.sHref = this.aHref[iTabIx];
  117.          this.sFrame = this.aFrame[iTabIx];
  118.          this.sHref2 = this.aHref2[iTabIx];
  119.          this.sFrame2 = this.aFrame2[iTabIx];
  120.          this.sHref = this.sHref.trim();
  121.          this.sFrame = this.sFrame.trim();
  122.          this.sHref2 = this.sHref2.trim();
  123.          this.sFrame2 = this.sFrame2.trim();
  124.          if (!this.sHref.toLowerCase().equals("none")) {
  125.             try {
  126.                ((Applet)this).getAppletContext().showDocument(new URL(((Applet)this).getCodeBase(), this.sHref), this.sFrame);
  127.             } catch (MalformedURLException var4) {
  128.             }
  129.          }
  130.  
  131.          if (!this.sHref2.toLowerCase().equals("none")) {
  132.             try {
  133.                ((Applet)this).getAppletContext().showDocument(new URL(((Applet)this).getCodeBase(), this.sHref2), this.sFrame2);
  134.                return;
  135.             } catch (MalformedURLException var3) {
  136.                return;
  137.             }
  138.          }
  139.       } catch (Exception var5) {
  140.       }
  141.  
  142.    }
  143.  
  144.    public void start() {
  145.       this.field_0 = ((Component)this).getGraphics();
  146.       this.paint(this.field_0);
  147.       this.thJAVATab = new Thread(this);
  148.       this.thJAVATab.start();
  149.    }
  150.  
  151.    public void stop() {
  152.       this.thJAVATab.stop();
  153.       this.thJAVATab = null;
  154.    }
  155.  
  156.    public void paint(Graphics g) {
  157.       ++this.iLoading;
  158.       g.drawString(this.sLoading, 10, 15);
  159.       g.drawString("Loading resource No." + this.iLoading + " - Please wait", 10, 35);
  160.    }
  161.  
  162.    public void run() {
  163.       if (!this.allLoaded) {
  164.          this.constructTab();
  165.          this.tabPanel1.show(true);
  166.          if (this.iTabDefault < 999) {
  167.             this.tabPanel1.setCurrentPanelNdx(this.iTabDefault);
  168.             this.tabPanel1_MouseUp((Event)null);
  169.             return;
  170.          }
  171.  
  172.          this.tabPanel1.setCurrentPanelNdx(0);
  173.       }
  174.  
  175.    }
  176.  
  177.    public void init() {
  178.       super.init();
  179.       ((Container)this).setLayout((LayoutManager)null);
  180.       ((Panel)this).addNotify();
  181.       this.tabPanel1 = new TabPanel();
  182.       this.tabPanel1.setLayout((LayoutManager)null);
  183.       switch (this.xSwitch) {
  184.          case 0:
  185.             this.sLoading = "1st JAVA Tab - Evaluation Copy";
  186.             break;
  187.          case 1:
  188.             this.sLoading = "1st JAVA Tab - Registered";
  189.             break;
  190.          case 2:
  191.             this.sLoading = "1st JAVA Tab";
  192.             break;
  193.          case 3:
  194.             this.sLoading = "1st JAVA Navigator[Tab] - Evaluation Copy";
  195.             break;
  196.          case 4:
  197.             this.sLoading = "1st JAVA Navigator[Tab] - Registered";
  198.       }
  199.  
  200.       ((Container)this).setLayout((LayoutManager)null);
  201.       ((Panel)this).addNotify();
  202.       ((Applet)this).resize(430, 270);
  203.    }
  204.  
  205.    private void constructTab() {
  206.       String strBG = "";
  207.  
  208.       try {
  209.          strBG = ((Applet)this).getParameter("COPYRIGHT");
  210.          if (strBG.indexOf(this.sCopyright) > 0) {
  211.             this.bCopyright = true;
  212.          } else {
  213.             this.bCopyright = false;
  214.          }
  215.       } catch (Exception var20) {
  216.       }
  217.  
  218.       try {
  219.          this.sMOUSEOVERSOUND = "none";
  220.          strBG = ((Applet)this).getParameter("MOUSEOVERSOUND");
  221.          if (strBG != null) {
  222.             this.sMOUSEOVERSOUND = strBG;
  223.          }
  224.       } catch (Exception var19) {
  225.       }
  226.  
  227.       try {
  228.          this.sMOUSECLICKSOUND = "none";
  229.          strBG = ((Applet)this).getParameter("MOUSECLICKSOUND");
  230.          if (strBG != null) {
  231.             this.sMOUSECLICKSOUND = strBG;
  232.          }
  233.       } catch (Exception var18) {
  234.       }
  235.  
  236.       try {
  237.          strBG = ((Applet)this).getParameter("TAB_BG");
  238.          if (strBG == null) {
  239.             this.iBGRed = 192;
  240.             this.iBGGreen = 192;
  241.             this.iBGBlue = 192;
  242.          } else {
  243.             this.iBGRed = this.getCOLOR(0, "TAB_BG", strBG);
  244.             this.iBGGreen = this.getCOLOR(1, "TAB_BG", strBG);
  245.             this.iBGBlue = this.getCOLOR(2, "TAB_BG", strBG);
  246.          }
  247.       } catch (Exception var17) {
  248.       }
  249.  
  250.       Dimension s = ((Component)this).size();
  251.       this.tabPanel1.reshape(0, 0, s.width, s.height);
  252.       this.tabPanel1.setBackground(new Color(this.iBGRed, this.iBGGreen, this.iBGBlue));
  253.  
  254.       try {
  255.          strBG = ((Applet)this).getParameter("TAB_FG");
  256.          if (strBG == null) {
  257.             this.iBGRed = 0;
  258.             this.iBGGreen = 0;
  259.             this.iBGBlue = 0;
  260.          } else {
  261.             this.iBGRed = this.getCOLOR(0, "TAB_FG", strBG);
  262.             this.iBGGreen = this.getCOLOR(1, "TAB_FG", strBG);
  263.             this.iBGBlue = this.getCOLOR(2, "TAB_FG", strBG);
  264.          }
  265.       } catch (Exception var16) {
  266.       }
  267.  
  268.       this.tabPanel1.setLabelColor(new Color(this.iBGRed, this.iBGGreen, this.iBGBlue));
  269.       ((Component)this).setForeground(new Color(this.iBGRed, this.iBGGreen, this.iBGBlue));
  270.  
  271.       try {
  272.          strBG = ((Applet)this).getParameter("TAB_DEFAULT");
  273.          if (strBG == null) {
  274.             this.iTabDefault = 999;
  275.          } else {
  276.             this.iTabDefault = Integer.parseInt(strBG);
  277.          }
  278.       } catch (Exception var15) {
  279.       }
  280.  
  281.       try {
  282.          strBG = ((Applet)this).getParameter("TABONBOTTOM");
  283.          if (strBG == null) {
  284.             this.tabPanel1.setTabsOnBottom(false);
  285.          } else {
  286.             this.tabPanel1.setTabsOnBottom(true);
  287.             if (strBG.toLowerCase().equals("no")) {
  288.                this.tabPanel1.setTabsOnBottom(false);
  289.             }
  290.          }
  291.       } catch (Exception var14) {
  292.       }
  293.  
  294.       try {
  295.          strBG = ((Applet)this).getParameter("TAB_FONT");
  296.          String fName = "";
  297.          String fStyle = "";
  298.          String fSize = "";
  299.          int iStyle = 0;
  300.          if (strBG != null) {
  301.             StringTokenizer parser = new StringTokenizer(strBG, ";");
  302.  
  303.             try {
  304.                fName = parser.nextToken();
  305.                fStyle = parser.nextToken();
  306.                fSize = parser.nextToken();
  307.                if (fStyle.trim().toLowerCase().equals("bold")) {
  308.                   iStyle = 1;
  309.                }
  310.  
  311.                if (fStyle.trim().toLowerCase().equals("italic")) {
  312.                   iStyle = 2;
  313.                }
  314.  
  315.                this.fFont = new Font(fName, iStyle, Integer.parseInt(fSize.trim()));
  316.             } catch (NoSuchElementException var11) {
  317.                System.out.println(strBG + " Parameter Error(1)");
  318.             } catch (Exception var12) {
  319.                System.out.println(strBG + " Parameter Error(2)");
  320.             }
  321.          }
  322.  
  323.          this.tabPanel1.setFont(this.fFont);
  324.       } catch (Exception var13) {
  325.       }
  326.  
  327.       try {
  328.          strBG = ((Applet)this).getParameter("TAB_MOUSEOVER");
  329.          if (strBG == null) {
  330.             this.iBGRed = 255;
  331.             this.iBGGreen = 0;
  332.             this.iBGBlue = 0;
  333.          } else {
  334.             this.iBGRed = this.getCOLOR(0, "TAB_MOUSEOVER", strBG);
  335.             this.iBGGreen = this.getCOLOR(1, "TAB_MOUSEOVER", strBG);
  336.             this.iBGBlue = this.getCOLOR(2, "TAB_MOUSEOVER", strBG);
  337.          }
  338.  
  339.          this.tabPanel1.setMOColor(new Color(this.iBGRed, this.iBGGreen, this.iBGBlue));
  340.       } catch (Exception var10) {
  341.       }
  342.  
  343.       try {
  344.          this.imgBG = null;
  345.          strBG = ((Applet)this).getParameter("TAB_BG_IMAGE");
  346.          if (strBG != null) {
  347.             this.imgBG = ((Applet)this).getImage(((Applet)this).getCodeBase(), strBG);
  348.             MediaTracker m = new MediaTracker(this);
  349.  
  350.             try {
  351.                m.addImage(this.imgBG, 0);
  352.                m.waitForAll();
  353.             } catch (InterruptedException var8) {
  354.                return;
  355.             }
  356.  
  357.             if (this.imgBG.getHeight(this) > 0) {
  358.                this.tabPanel1.setBGImage(this.imgBG);
  359.             }
  360.          }
  361.       } catch (Exception var9) {
  362.       }
  363.  
  364.       ((Container)this).add(this.tabPanel1);
  365.       this.tabPanel1.show(false);
  366.  
  367.       int i;
  368.       for(i = 0; ((Applet)this).getParameter("TAB" + i) != null; ++i) {
  369.       }
  370.  
  371.       this.iTabCnt = i + 1;
  372.       this.tempString = new String[this.iTabCnt];
  373.       this.aHref = new String[this.iTabCnt];
  374.       this.aFrame = new String[this.iTabCnt];
  375.       this.aHref2 = new String[this.iTabCnt];
  376.       this.aFrame2 = new String[this.iTabCnt];
  377.       this.aMsg = new String[this.iTabCnt];
  378.  
  379.       for(int var34 = 0; ((Applet)this).getParameter("TAB" + var34) != null; ++var34) {
  380.          this.workParam(((Applet)this).getParameter("TAB" + var34), var34);
  381.          this.tabPanel1.add(this.label1);
  382.          if (var34 == 0 && (this.xSwitch == 0 || this.xSwitch == 3)) {
  383.             this.tabPanel1.add(this.label1);
  384.          }
  385.       }
  386.  
  387.       if (!this.bCopyright) {
  388.          this.tempString[0] = "Copyright parameter missing";
  389.          this.aMsg[0] = "Copyright applet parameter missing in the HTML code.";
  390.       }
  391.  
  392.       this.tabPanel1.setPanelLabels(this.tempString);
  393.       this.tabPanel1.show();
  394.       this.allLoaded = true;
  395.    }
  396.  
  397.    public boolean handleEvent(Event event) {
  398.       if (event.target == this.tabPanel1 && event.id == 503) {
  399.          this.tabPanel1_MouseMove(event);
  400.          return true;
  401.       } else if (event.target == this.tabPanel1 && event.id == 502) {
  402.          this.tabPanel1_MouseMove(event);
  403.          return true;
  404.       } else {
  405.          return super.handleEvent(event);
  406.       }
  407.    }
  408.  
  409.    private int getCOLOR(int iColor, String sWhat, String sPBG) {
  410.       int iRed = 255;
  411.       int iBlue = 255;
  412.       int iGreen = 255;
  413.       StringTokenizer parser = new StringTokenizer(sPBG, ",");
  414.  
  415.       try {
  416.          String sRed = parser.nextToken();
  417.          String sGreen = parser.nextToken();
  418.          String sBlue = parser.nextToken();
  419.          iRed = Integer.parseInt(sRed);
  420.          iGreen = Integer.parseInt(sGreen);
  421.          iBlue = Integer.parseInt(sBlue);
  422.       } catch (NoSuchElementException var11) {
  423.          System.out.println(sWhat + " Parameter Error(1)");
  424.       } catch (Exception var12) {
  425.          System.out.println(sWhat + " Parameter Error(2)");
  426.       }
  427.  
  428.       switch (iColor) {
  429.          case 0:
  430.             return iRed;
  431.          case 1:
  432.             return iGreen;
  433.          case 2:
  434.             return iBlue;
  435.          default:
  436.             return 255;
  437.       }
  438.    }
  439.  
  440.    private void workParam(String sItem, int iTCnt) {
  441.       this.sHref = "None";
  442.       this.sFrame = "None";
  443.       this.sHref2 = "None";
  444.       this.sFrame2 = "None";
  445.       this.sMsg = "None";
  446.       if (sItem.substring(0, 3).equals("***")) {
  447.          this.sHref = "None";
  448.          this.sFrame = "None";
  449.          this.sHref2 = "None";
  450.          this.sFrame2 = "None";
  451.          this.sMsg = "None";
  452.       } else {
  453.          StringTokenizer parser = new StringTokenizer(sItem, ";");
  454.          int iCnt = parser.countTokens() - 4;
  455.          if (iCnt != 0 && iCnt != 2) {
  456.             System.out.println("*** Warning in parameter '" + sItem + "' - Item count is ( " + parser.countTokens() + " ) instead of ( 6 ) *** ");
  457.          }
  458.  
  459.          try {
  460.             this.sText = parser.nextToken();
  461.             this.sHref = parser.nextToken();
  462.             this.sFrame = parser.nextToken();
  463.             this.sMsg = parser.nextToken();
  464.             this.sHref2 = parser.nextToken();
  465.             this.sFrame2 = parser.nextToken();
  466.          } catch (NoSuchElementException var6) {
  467.          } catch (Exception var7) {
  468.             System.out.println(sItem + " Parameter Error(3)");
  469.          }
  470.  
  471.          if (iTCnt == 0 && (this.xSwitch == 0 || this.xSwitch == 3)) {
  472.             this.tempString[iTCnt] = "Evaluation Copy";
  473.             this.aHref[iTCnt] = "http://www.auscomp.com";
  474.             this.aFrame[iTCnt] = "_blank";
  475.             this.aHref2[iTCnt] = "None";
  476.             this.aFrame2[iTCnt] = "None";
  477.             this.aMsg[iTCnt] = this.sDefMO;
  478.          }
  479.  
  480.          if (iTCnt == 0 && this.xSwitch == 2) {
  481.             try {
  482.                this.fAuscomp = false;
  483.                if (((Applet)this).getCodeBase().equals(new URL("http://10.0.0.2/JTab/"))) {
  484.                   this.fAuscomp = true;
  485.                } else {
  486.                   if (((Applet)this).getCodeBase().equals(new URL("http://www.auscomp.com/JTab/"))) {
  487.                      this.fAuscomp = true;
  488.                   }
  489.  
  490.                   if (((Applet)this).getCodeBase().equals(new URL("http://www.auscomp.com.au/JTab/"))) {
  491.                      this.fAuscomp = true;
  492.                   }
  493.                }
  494.             } catch (MalformedURLException var5) {
  495.             }
  496.  
  497.             if (!this.fAuscomp) {
  498.                this.tempString[iTCnt] = "Illegal copy of 1st JAVA Tab";
  499.                this.aHref[iTCnt] = "http://www.auscomp.com";
  500.                this.aFrame[iTCnt] = "_blank";
  501.                this.aHref2[iTCnt] = "None";
  502.                this.aFrame2[iTCnt] = "None";
  503.                this.aMsg[iTCnt] = "Non registered copy of 1st JAVA Navigator (c)1997-2000 Auscomp (www.auscomp.com)";
  504.                this.tabPanel1.add(this.label1);
  505.             }
  506.          }
  507.  
  508.          if (this.xSwitch == 0 || this.xSwitch == 3) {
  509.             ++iTCnt;
  510.          }
  511.  
  512.          if (this.xSwitch == 2 && !this.fAuscomp) {
  513.             ++iTCnt;
  514.          }
  515.  
  516.          this.tempString[iTCnt] = this.sText;
  517.          this.aHref[iTCnt] = this.sHref;
  518.          this.aFrame[iTCnt] = this.sFrame;
  519.          this.aHref2[iTCnt] = this.sHref2;
  520.          this.aFrame2[iTCnt] = this.sFrame2;
  521.          this.aMsg[iTCnt] = this.sMsg;
  522.       }
  523.    }
  524. }
  525.